<html>
<head>
<title>
Database - Helma Javascript Reference
</title>

<meta http-equiv="Content-Script-Type" content="text/javascript">
<script src="scripts.js"></script>
<link rel="stylesheet" href="styles.css" media="screen" />
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
    <script type="text/javascript">_uacct = "UA-737027-2";urchinTracker();</script>
<style>
td {
    font-family: "Trebuchet MS", sans-serif; 
    font-size: 13px; 
    line-height:135%;
}
.columnheight {
    height: 1350px;
}
</style>
</head>
<body bgcolor="white">

<div class="frame">

<img class="home" onclick="location='http://dev.helma.org/'" src="helmaheader.gif" /><br />
<div class="lead">
    <p>Detailed reference of prototypes, properties and methods available in the <br />
    Javascript environment of your Helma web applications.</p>
</div>

<script> openbox('content') </script>


    <div class="content">
        <div class="docs">
        
            <!--
            <div class="sectionHead">Library: Database.js</div>
            -->
            <div class="section overview">
            <!--
                <div class="itemTitle">
                    Overview
                </div>
            -->
                <div>   
                    <div class="desc">Properties and methods of the helma.Database prototype.
<br /><br />
To use this optional module, its repository needs to be added to the 
application, for example by calling app.addRepository('modules/helma/Database.js')</div>
                    <div class="itemTags">
            <!--
                    <ul>
                        
                    
                    </ul>
            -->
                    </div>
                </div>
            </div>
            
            <!--
            <div class="sectionHead">Constructors</div>
            -->
            
            
            <div class="section constructor">
                <div class="itemTitle">
                    <a name="helma.Database"></a>
                    
                    
                        <i><a href="#helma" class="type">helma</a>
                        <span class="symbolname">Database</span>(<span class="signature">source</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Constructor for Database objects, providing access through relational
databases through JDBC. It is usually simpler to use one of the factory
methods {@link #createInstance} or {@link #getInstance}.</div>
                
                
                
                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            DbSource
                        </td>
                        <td>
                            source
                        </td>
                        <td>
                            instance of a helma.objectmodel.db.DbSource
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">methods</div>
                
                    <ul class="details">
                        <li><a href="#helma.Database.getConnection">getConnection</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.getProductName">getProductName</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.isOracle">isOracle</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.isMySql">isMySql</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.isPostgreSql">isPostgreSql</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.query">query</a>(sql)</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.execute">execute</a>(sql)</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.getName">getName</a>()</li>
                    </ul>
                
                    <ul class="details">
                        <li><a href="#helma.Database.getDriverName">getDriverName</a>()</li>
                    </ul>
                
                
                
                
                
                
                
                

                

            </div>
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <!--
            <div class="sectionHead">Namespaces</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <!--
            <div class="sectionHead">Properties</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            

            <!--
            <div class="sectionHead">Constructors</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <div class="sectionHead">Methods</div>
            
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.getConnection"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">getConnection</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the java.sql.Connection for this Database instance. This can be used
to operate on the connection directly, without going through the helma.Database
class.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            java.sql.Connection
                        </td>
                        <td>
                            the JDBC connection
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.getProductName"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">getProductName</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Returns the lower case name of the underlying database product.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            the name of the DB product
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.isOracle"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">isOracle</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Returns true if this is an Oracle database.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            boolean
                        </td>
                        <td>
                            true if this is an Oracle database.
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.isMySql"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">isMySql</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Returns true if this is a MySQL database.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            boolean
                        </td>
                        <td>
                            true if this is an MySQL database.
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.isPostgreSql"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">isPostgreSql</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Returns true if this is a PostgreSQL database.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            boolean
                        </td>
                        <td>
                            true if this is a PostgreSQL database.
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.query"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">query</span>(<span class="signature">sql</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Executes the given SQL statement. The result set is returned
as JavaScript Array containing a JavaScript Object for each result.</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            sql
                        </td>
                        <td>
                            an SQL query statement
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            Array
                        </td>
                        <td>
                            an Array containing the result set
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.execute"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">execute</span>(<span class="signature">sql</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Executes the given SQL statement, which may be an INSERT, UPDATE,
or DELETE statement or an SQL statement that returns nothing,
such as an SQL data definition statement. The return value is an integer that
indicates the number of rows that were affected by the statement.</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            sql
                        </td>
                        <td>
                            an SQL statement
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            int
                        </td>
                        <td>
                            either the row count for INSERT, UPDATE or
DELETE statements, or 0 for SQL statements that return nothing
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.getName"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">getName</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the name of the Helma DbSource object.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            the DbSource name
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.getDriverName"></a>
                    
                    
                        <i><a href="#helma.Database" class="type">helma.Database</a>.
                        <span class="symbolname">getDriverName</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the name of the JDBC driver used by this Database instance.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            the JDBC driver name
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.createInstance"></a>
                    
                    
                        <i><a href="#helma" class="type">helma</a>.
                        <span class="symbolname">Database.createInstance</span>(<span class="signature">driver, url, name, user, password</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Create a new Database instance using the given parameters.
<p>Some of the parameters support shortcuts for known database products.
The <code>url</code> parameter recognizes the values "mysql", "oracle" and
"postgresql". For those databases, it is also possible to pass just
<code>hostname</code> or <code>hostname:port</code> as <code>url</code>
parameters instead of the full JDBC URL.</p></div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            driver
                        </td>
                        <td>
                            the class name of the JDBC driver. As
shortcuts, the values "mysql", "oracle" and "postgresql" are
recognized.
                        </td> 
                    </tr>
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            url
                        </td>
                        <td>
                            the JDBC URL.
                        </td> 
                    </tr>
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            name
                        </td>
                        <td>
                            the name of the database to use
                        </td> 
                    </tr>
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            user
                        </td>
                        <td>
                            the the username
                        </td> 
                    </tr>
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            password
                        </td>
                        <td>
                            the password
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            helma.Database
                        </td>
                        <td>
                            a helma.Database instance
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="helma.Database.getInstance"></a>
                    
                    
                        <i><a href="#helma" class="type">helma</a>.
                        <span class="symbolname">Database.getInstance</span>(<span class="signature">name</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get a Database instance using the Database source defined in the
application's db.properties file with the given name.</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            name
                        </td>
                        <td>
                            the name of the DB source as defined in db.properties
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            helma.Database
                        </td>
                        <td>
                            a helma.Database instance
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
        </div>
    </div>
    <div class="finePrint">
    Fri, 05 Feb 2010 17:40:05 GMT.
    </div>

<script> closebox() </script>

<script> openbox('pageintro') </script>

    <h3>core framework</h3>
        <ul>            
            <li><a href="global.html">global</a></li>
            <li><a href="app.html">app (application)</a></li>
            <li><a href="req.html">req (request)</a></li>
            <li><a href="res.html">res (response)</a></li>
            <li><a href="session.html">session</a></li>
            <li><a href="global.html#path">path</a></li>
            <li><a href="global.html#root">root</a></li>
            <li><a href="HopObject.html">HopObject</a></li>
            <li><a href="User.html">User</a></li>
            <li><a href="File.html">File</a></li>
            <li><a href="FtpClient.html">FtpClient</a></li>
            <li><a href="Image.html">Image</a></li>
            <li><a href="Mail.html">Mail</a></li>
            <li><a href="global.html#Remote">Remote</a></li>
            <li><a href="Xml.html">Xml</a></li>
            <li><a href="DatabaseObject.html">DatabaseObject</a></li>
            <li><a href="MimePart.html">MimePart</a></li>
            <li><a href="Skin.html">Skin</a></li>
            <li><a href="global.html#Object.dontEnum">Object</a></li>
        </ul>
        
    <h3>optional modules</h3>
        <ul>            
            <li><a href="ArrayExtensions.html">Array extensions</a></li>
            <li><a href="DateExtensions.html">Date extensions</a></li>
            <li><a href="NumberExtensions.html">Number extensions</a></li>
            <li><a href="ObjectExtensions.html">Object extensions</a></li>
            <li><a href="StringExtensions.html">String extensions</a></li>
            <li><a href="HopObjectExtensions.html">HopObject extensions</a></li>
            <li><a href="GlobalMacros.html">global macros</a></li>
            <li><a href="MacroFilters.html">macro filters</a></li>
            <li><a href="JSON.html">JSON methods</a></li>
            <br />
            <li><a href="helma.Aspects.html">helma.Aspects</a></li>
            <li><a href="helma.Chart.html">helma.Chart</a></li>
            <li><a href="helma.Color.html">helma.Color</a></li>
            <li><a href="helma.Database.html">helma.Database</a></li>
            <li><a href="helma.File.html">helma.File</a></li>
            <li><a href="helma.Ftp.html">helma.Ftp</a></li>
            <li><a href="helma.Group.html">helma.Group</a></li>
            <li><a href="helma.Html.html">helma.Html</a></li>
            <li><a href="helma.Http.html">helma.Http</a></li>
            <li><a href="helma.Image.html">helma.Image</a></li>
            <li><a href="helma.Mail.html">helma.Mail</a></li>
            <li><a href="helma.Search.html">helma.Search</a></li>
            <li><a href="helma.Skin.html">helma.Skin</a></li>
            <li><a href="helma.Ssh.html">helma.Ssh</a></li>
            <li><a href="helma.Url.html">helma.Url</a></li>
            <li><a href="helma.Zip.html">helma.Zip</a></li>
            <br />
            <li><a href="jala.BitTorrent.html">jala.BitTorrent</a></li>
            <li><a href="jala.Captcha.html">jala.Captcha</a></li>
            <li><a href="jala.Date.html">jala.Date</a></li>
            <li><a href="jala.db.html">jala.db</a></li>
            <li><a href="jala.DnsClient.html">jala.DnsClient</a></li>
            <li><a href="jala.Form.html">jala.Form</a></li>
            <li><a href="jala.History.html">jala.History</a></li>
            <li><a href="jala.HopObjectExtensions.html">jala HopObject extensions</a></li>
            <li><a href="jala.HtmlDocument.html">jala.HtmlDocument</a></li>
            <li><a href="jala.I18n.html">jala.I18n</a></li>
            <li><a href="jala.ImageFilter.html">jala.ImageFilter</a></li>
            <li><a href="jala.IndexManager.html">jala.IndexManager</a></li>
            <li><a href="jala.ListRenderer.html">jala.ListRenderer</a></li>
            <li><a href="jala.Mp3.html">jala.Mp3</a></li>
            <li><a href="jala.PodcastWriter.html">jala.PodcastWriter</a></li>
            <li><a href="jala.RemoteContent.html">jala.RemoteContent</a></li>
            <li><a href="jala.Rss20Writer.html">jala.Rss20Writer</a></li>
            <li><a href="jala.Utilities.html">jala.Utilities</a></li>
            <li><a href="jala.XmlRpcRequest.html">jala.XmlRpcRequest</a></li>
            <li><a href="jala.XmlWriter.html">jala.XmlWriter</a></li>
        </ul>
    
    <h3>java libraries</h3>
        <ul>            
            <li><a href="http://www.docjar.org/">docjar search</a></li>
        </ul>

    <h3>properties files</h3>
        <ul>            
            <li><a href="http://dev.helma.org/docs/Properties+Files/apps.properties/">apps.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/app.properties/">app.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/server.properties/">server.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/db.properties/">db.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/class.properties/">class.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Type.properties+Documentation/">type.properties</a></li>
         </ul>
    
<script> closebox() </script>

</div>
<br clear="all" /><br /><br />



</body>
</html>
